home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 22 April 1997
- // Author: sjt
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // int action
- // 0 - just execute the extend curve operation
- // 1 - show the option box dialog
- // 2 - drag to shelf
- //
- // Return Value:
- // None.
- //
- // Notes:
- // In the future this can be modified to include extend to object
- //
- global proc extendCurveEnableBoth( string $joinWidget,
- string $methodWidget,
- string $endWidget,
- string $knotsWidget,
- string $originalsWidget,
- int $priorityEnd )
- {
- int $enable;
- if( $priorityEnd ) {
- int $end = `radioButtonGrp -q -select $endWidget`;
- if( 3 == $end ) {
- $enable = 0;
- }
- else {
- $enable = 1;
- }
- radioButtonGrp -edit -enable2 $enable $methodWidget;
- checkBoxGrp -edit -enable $enable $joinWidget;
-
- $enable = `checkBoxGrp -q -value1 $joinWidget`;
- checkBoxGrp -edit -enable $enable $knotsWidget;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- else {
- int $join = `checkBoxGrp -q -value1 $joinWidget`;
- int $method = `radioButtonGrp -q -select $methodWidget`;
- if( $join && (1 == $method)) {
- $enable = 1;
- }
- else {
- $enable = 0;
- }
-
- radioButtonGrp -edit -enable3 $enable $endWidget;
-
- $enable = $join;
- checkBoxGrp -edit -enable $enable $knotsWidget;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- }
-
- proc setOptionVars(int $forceFactorySettings)
- {
- // Extend Method ( 0 = by distance or 2 = to point ).
- // Default = 0 = by distance
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveMethod`) {
- optionVar -intValue extendCurveMethod 0;
- }
-
- // Extension Type ( 0 = linear or 1 = cicular or 2 = extrapolate ).
- // Used only if extend method is 0
- // Default = 0 = linear
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveType`) {
- optionVar -intValue extendCurveType 0;
- }
-
- // Extend Distance.
- // Used only if extend method is 0
- // Default = 1.00
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveDistance`) {
- optionVar -floatValue extendCurveDistance 1.0;
- }
-
- // Extend To Point.
- // Used only if extend method is 2
- // Default = 0.0, 0.0, 0.0
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveToPointX`) {
- optionVar -floatValue extendCurveToPointX 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists extendCurveToPointY`) {
- optionVar -floatValue extendCurveToPointY 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists extendCurveToPointZ`) {
- optionVar -floatValue extendCurveToPointZ 0.0;
- }
-
- // Extend Start ( 1 = start or 0 = end, 2 = both )
- // Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveStart`) {
- optionVar -intValue extendCurveStart 0;
- }
-
- // Extend Join ( on = join or off = do not join )
- // Default = ON
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveJoin`) {
- optionVar -intValue extendCurveJoin 1;
- }
-
- // Extend Remove Multiple Knots ( on = remove or off = do not remove )
- // Used only when joining
- // Default = OFF
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveRemoveMultKnots`) {
- optionVar -intValue extendCurveRemoveMultKnots 1;
- }
-
- // keep original (for in place operations is on-1 or off-0 )
- // Used only when joining
- /// Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendCurveKeepOriginal`) {
- optionVar -intValue extendCurveKeepOriginal 0;
- }
-
- }
-
- //
- // Procedure Name:
- // extendCurveSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the extend curve
- // option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc extendCurveSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- extendCurveToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Extend Method
- //
- int $method = `optionVar -query extendCurveMethod`;
- radioButtonGrp -e -sl ($method+1) extendCurveMethodBtn;
-
- // extend distance
- floatSliderGrp -edit
- -value `optionVar -query extendCurveDistance`
- extendCurveDistanceSlider;
-
- // extend type
- int $extendType = `optionVar -query extendCurveType`;
- int $realExtendType = $extendType + 1 ;
- radioButtonGrp -edit
- -select $realExtendType
- extendCurveTypeBtn;
-
- // extend point
- float $x = `optionVar -q extendCurveToPointX`;
- float $y = `optionVar -q extendCurveToPointY`;
- float $z = `optionVar -q extendCurveToPointZ`;
- floatFieldGrp -e -v1 $x extendCurveToPointFloatFieldGrp;
- floatFieldGrp -e -v2 $y extendCurveToPointFloatFieldGrp;
- floatFieldGrp -e -v3 $z extendCurveToPointFloatFieldGrp;
-
-
- // extend start and join
- //
- int $join = `optionVar -query extendCurveJoin`;
- int $start = `optionVar -query extendCurveStart`;
-
- // convert from value to button number
- // ( 1 = start or 0 = end, 2 = both )
- switch( $start ) {
- case 0:
- $start = 2;
- break;
- case 1:
- $start = 1;
- break;
- case 2:
- default:
- $start = 3;
- break;
- }
-
- radioButtonGrp -e
- extendCurveMethodBtn;
-
- radioButtonGrp -edit
- -select $start
- extendCurveStartBtn;
-
- // Extend join
- //
- checkBoxGrp -edit
- -value1 $join
- extendCurveJoinBox;
-
- // Remove Multiple Knots
- //
- checkBoxGrp -edit
- -value1 `optionVar -query extendCurveRemoveMultKnots`
- -enable ($join && (3 != $start))
- extendCurveRemoveMultKnotsBox;
-
- // Keep original.
- //
- checkBoxGrp -edit
- -value1 `optionVar -query extendCurveKeepOriginal`
- -enable ($join && (3 != $start))
- extendCurveKeepOriginalBox;
-
- extendCurveEnableBoth( "extendCurveJoinBox",
- "extendCurveMethodBtn",
- "extendCurveStartBtn",
- "extendCurveRemoveMultKnotsBox",
- "extendCurveKeepOriginalBox",
- 0 );
-
- // Do the visibility here (distance vs. point):
- if( 0 == $method ) {
- tabLayout -e -st extendCurveDistance_tab extendCurveMethodOptions;
- }
- else {
- tabLayout -e -st extendCurveToPoint_tab extendCurveMethodOptions;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // extendCurveCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc extendCurveCallback(string $parent, int $doIt, string $goToTool)
- {
- if( "" != $goToTool ) {
- optionVar -iv extendCurveEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv extendCurveLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Extend Method.
- //
- int $method = `radioButtonGrp -query -select extendCurveMethodBtn`;
- int $saveMethod = $method - 1 ;
- optionVar -intValue extendCurveMethod $saveMethod;
-
- if( $saveMethod == 0 ) {
- // Extend Type
- //
- int $extendType = `radioButtonGrp -query -select extendCurveTypeBtn`;
- int $saveExtendType = $extendType - 1 ;
- optionVar -intValue extendCurveType $saveExtendType;
-
- // extend distance
- //
- optionVar -floatValue extendCurveDistance
- `floatSliderGrp -query -value extendCurveDistanceSlider`;
- }
- else {
- // extend to point.
- //
- float $x = `floatFieldGrp -q -v1 extendCurveToPointFloatFieldGrp` ;
- float $y = `floatFieldGrp -q -v2 extendCurveToPointFloatFieldGrp` ;
- float $z = `floatFieldGrp -q -v3 extendCurveToPointFloatFieldGrp` ;
- optionVar -floatValue extendCurveToPointX $x ;
- optionVar -floatValue extendCurveToPointY $y ;
- optionVar -floatValue extendCurveToPointZ $z ;
- }
-
- // Start or end or both
- // ( 1 = start or 0 = end, 2 = both )
- int $start = `radioButtonGrp -query -select extendCurveStartBtn`;
-
- // convert from button number to value
- switch( $start ) {
- case 1:
- $start = 1;
- break;
- case 2:
- $start = 0;
- break;
- case 3:
- default:
- $start = 2;
- break;
- }
- optionVar -intValue extendCurveStart $start;
-
- // Join
- //
- optionVar -intValue extendCurveJoin
- `checkBoxGrp -query -value1 extendCurveJoinBox`;
-
- // Remove Multiple knots
- //
- optionVar -intValue extendCurveRemoveMultKnots
- `checkBoxGrp -query -value1 extendCurveRemoveMultKnotsBox`;
-
- // Keep original.
- //
- optionVar -intValue extendCurveKeepOriginal
- `checkBoxGrp -query -value1 extendCurveKeepOriginalBox`;
-
- if (1 == $doIt) {
- performExtendCurve( 0, $goToTool );
- string $tmpCmd = "performExtendCurve( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Extend Curve";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // createExtendCurveUI
- //
- // Description:
- // Fill the contents of the option box for extendCurve command.
- //
- // Input Arguments:
- // The name of the parent layout.
- //
- // Return Value:
- // None.
- //
- proc createExtendCurveUI(string $parent, int $inTheTool, string $goToTool)
- {
- setParent $parent;
-
- string $methodWidget = `radioButtonGrp -label "Extend Method"
- -numberOfRadioButtons 2
- -label1 "Distance" -da1 0
- -label2 "Point" -da2 2
- extendCurveMethodBtn`;
-
- tabLayout -tabsVisible false extendCurveMethodOptions;
- columnLayout extendCurveDistance_tab;
- radioButtonGrp -label "Extension Type"
- -numberOfRadioButtons 3
- -label1 "Linear" -da1 0
- -label2 "Circular" -da2 1
- -label3 "Extrapolate" -da3 2
- extendCurveTypeBtn;
-
- floatSliderGrp -label "Distance"
- -field true
- -min 0.0
- -max 100.0
- extendCurveDistanceSlider;
- setParent ..;
-
- columnLayout extendCurveToPoint_tab;
- floatFieldGrp -l "Point To Extend To"
- -nf 3
- extendCurveToPointFloatFieldGrp;
- setParent ..;
- setParent ..;
-
- separator;
-
- string $endWidget = `radioButtonGrp -label "Extend Curve at"
- -numberOfRadioButtons 3
- -label1 "Start" -da1 1 -enable1 1
- -label2 "End" -da2 0 -enable2 1
- -label3 "Both" -da3 0 -enable3 1
- extendCurveStartBtn`;
-
- string $joinWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Join to Original"
- extendCurveJoinBox`;
-
- string $knotsWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Remove Multiple Knots"
- extendCurveRemoveMultKnotsBox`;
-
- string $originalsWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Keep Original"
- extendCurveKeepOriginalBox`;
-
- radioButtonGrp -edit
- -onCommand1 (
- "tabLayout -e -selectTab extendCurveDistance_tab " +
- "extendCurveMethodOptions;"
- + "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- -onCommand2 (
- "tabLayout -e -selectTab extendCurveToPoint_tab " +
- "extendCurveMethodOptions;"
- + "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- $methodWidget;
-
- radioButtonGrp -edit
- -onCommand1 (
- "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand2 (
- "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand3 (
- "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 1;"
- )
- $endWidget;
-
- checkBoxGrp -edit
- -onCommand (
- "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- -offCommand (
- "extendCurveEnableBoth"
- + " " + $joinWidget
- + " " + $methodWidget
- + " " + $endWidget
- + " " + $knotsWidget
- + " " + $originalsWidget + " 0;"
- )
- $joinWidget;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
- }
-
-
- //
- // Procedure Name:
- // extendCurveOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc extendCurveOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "extendCurve";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolExtendCurve";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "extendCurveToolScript 3";
-
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- // Any default option box behavior based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // RECOMMENDATION: Place the UI in a scroll layout. If the
- // option box window is ever resized such that it's entire
- // contents is not visible then the scroll bars provided by the
- // scroll layout will allow the user to access the hidden UI.
- //
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the UI for the tab that is initially visible.
- //
- createExtendCurveUI($parent, $inTheTool, $goToTool);
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'ExtendCurve' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Extend Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Extend"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Set the option box title.
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Extend Curve Tool Options");
- }
- else {
- setOptionBoxTitle("Extend Curve Options");
- }
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "ExtendCurve" );
-
- // Set the current values of the option box.
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // extendCurveHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string extendCurveHelp()
- {
- return
- " Command: extendCurve - extends a curve\n" +
- "Selection: a curve ";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // The extendCurve command string.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- // get the global history flag value
- int $doHistory = `constructionHistory -q -tgl`;
-
- int $method = `optionVar -query extendCurveMethod`;
- int $extendType = `optionVar -query extendCurveType`;
- float $distance = `optionVar -query extendCurveDistance`;
- float $toPointx = `optionVar -query extendCurveToPointX`;
- float $toPointy = `optionVar -query extendCurveToPointY`;
- float $toPointz = `optionVar -query extendCurveToPointZ`;
-
- int $start = `optionVar -query extendCurveStart`;
- int $join = `optionVar -query extendCurveJoin`;
- int $removeMultKnots = `optionVar -query extendCurveRemoveMultKnots`;
- int $replaceOriginal = !`optionVar -q extendCurveKeepOriginal`;
-
-
- // set up string for preset function call
- // Note that extendCurvePresetArgList() takes a string array.
- // The command will look something like:
- // extendCurvePresetArgList( "2", { "0", "1","0","1","1.5", .... ,"1","0"});
- //
- string $version = "\"2\"";
- string $cmd = "extendCurvePresetArgList";
- $cmd = $cmd + "( ";
- $cmd = $cmd + $version;
- $cmd = $cmd + ", {\"0\", \"" ;
- $cmd = $cmd + $doHistory;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $method;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $extendType;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $distance;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $toPointx;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $toPointy;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $toPointz;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $start;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $join;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $removeMultKnots;
- $cmd = $cmd + "\",\"";
- $cmd = $cmd + $replaceOriginal;
- $cmd = $cmd + "\"} )";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performExtendCurve
- //
- // Description:
- // Perform the optionBoxExample1 command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the optionBoxExample1 command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- // 3 - Show the tool option box dialog.
- //
- // Return Value:
- // None.
- //
- global proc string performExtendCurve(int $action, string $goToTool)
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- case 1:
- extendCurveOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-